#include "gui_protocol_engine.h"

#include "types.h"
#include "logger.h"
#include "ui_socket.h"

const std::string CGuiProtocolEngine::sIniSectionName("NO_SECTION"); // TODO

CGuiProtocolEngine::CGuiProtocolEngine(CPropertiesReader* pConfig) :
	mConfig(pConfig)
{
}

CGuiProtocolEngine::~CGuiProtocolEngine()
{
}

bool CGuiProtocolEngine::open()
{
	return CUISocket::getInstance()->sendProtocolOpen();
}

void CGuiProtocolEngine::close()
{
	CUISocket::getInstance()->sendProtocolClose();
}

NStegIO::EReadState CGuiProtocolEngine::read(unsigned char& pReadValue)
{
	if (CUISocket::getInstance()->getNextProtocolReadByte(pReadValue)) {
		return NStegIO::READ_STATE_DATA;
	}
	return NStegIO::READ_STATE_NODATA;
}

void CGuiProtocolEngine::write(unsigned char pWriteValue)
{
	CUISocket::getInstance()->sendProtocolWrite(&pWriteValue, 1);
}

int CGuiProtocolEngine::available()
{
	// TODO currently no implementation
	return 0;
}
